#include "process.h"

void process_v1()
{
	char ch[NUM];
	memset(ch, 0, sizeof(ch));
	char ch1[5]="/-\\|\0";

	for(int i=1;i<(NUM);i++)
	{
		ch[i-1]='#';
		printf("[%-100s][%d\%]",ch,i);
		printf("[%c]\r",ch1[i%4]);
		fflush(stdout);
		usleep(100000);
	}
	printf("\n");
}

void FlashProcess(double allsize, double newsize)
{
    assert(allsize >= newsize);
    char buffer[NUM];
    memset(buffer, 0, sizeof(buffer));
    char lable[4] = { '/','-', '\\', '|' };
    int lablen = sizeof(lable);
    static int count = 0;
    double d_rate = (newsize / allsize) * 100;
    int i_rate = (int)d_rate;
    memset(buffer, FILL, sizeof(char)* i_rate);
    printf("[%-100s][%0.2ff%%]", buffer, d_rate);
    printf("[%c]\r", lable[count % lablen]);
    fflush(stdout);
    count++;
}

